package com.ebupt.migu.music.unifyAudit.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ebupt.migu.music.unifyAudit.pojo.UnifyAudit;

import java.util.List;

/**
 * 统一审核能力记录表
 * @author tz
 */
@DS("mysql_mg")
public interface UnifyAuditMapper extends BaseMapper<UnifyAudit> {

    /**
     * 根据策略id查审核记录
     * @param strategyId
     * @return
     */
    default List<UnifyAudit> qryByStrategyId(String strategyId){
        return this.selectList(new QueryWrapper<UnifyAudit>().lambda().eq(UnifyAudit::getStrategyId,strategyId));
    }

    /**
     * 查询策略最后一次审批记录
     * @param strategyId
     * @return
     */
    default UnifyAudit lastAudit(String strategyId){
        return this.selectOne(new QueryWrapper<UnifyAudit>().lambda().eq(UnifyAudit::getStrategyId,strategyId)
        .orderByDesc(UnifyAudit::getId).last("limit 1"));
    }

}